package com.niit.agricstore.controller;

import com.fasterxml.jackson.annotation.JsonRawValue;
import com.niit.agricstore.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Component
@RequestMapping("/")
public class BaseController {
    @Autowired
    RedisService redisService;
    @RequestMapping("/")
    public String index(Model model){
    System.out.println("进入访问====");
    redisService.incr("count",1);    //没访问一次，那么访问量就加1
    System.out.println(redisService.get("count"));
    model.addAttribute("counts",redisService.get("count"));  //将数据传回前端
    return "/index";
}
}
